]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Network Menu: fix pulling out the first element from the More... submenu.
authorGiovanni Campagna <gcampagna@src.gnome.org>
Mon, 17 Oct 2011 12:43:08 +0000 (14:43 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Thu, 3 Nov 2011 12:12:03 +0000 (13:12 +0100)
PopupMenu.firstMenuItem returns a PopupMenuItem, not an apObj. We
need to retrive the latter using the _apObj property.

Also, somehow the property from the number of elements in a menu
was changed from .length to .numMenuItems, and this broke the
destruction of the menu upon emptying it.

https://bugzilla.gnome.org/show_bug.cgi?id=659277

js/ui/status/network.js

index 966e8726c5e81ada7c6424496769d86d187e412b..456b51fe457f7552d0cc42d9d3cd5831e9c622bc 100644 (file)
@@ -1307,17 +1307,21 @@ NMDeviceWireless.prototype = {
                     // we removed an item in the main menu, and we have a more submenu
                     // we need to extract the first item in more and move it to the submenu
 
-                    let apObj = this._overflowItem.menu.firstMenuItem;
-                    if (apObj.item) {
-                        apObj.item.destroy();
+                    let item = this._overflowItem.menu.firstMenuItem;
+                    if (item && item._apObj) {
+                        item.destroy();
+                        // clear the cycle, and allow the construction of the new item
+                        item._apObj.item = null;
 
-                        this._createNetworkItem(apObj, NUM_VISIBLE_NETWORKS-1);
+                        this._createNetworkItem(item._apObj, NUM_VISIBLE_NETWORKS-1);
+                    } else {
+                        log('The more... menu was existing and empty! This should not happen');
                     }
                 }
 
                 // This can happen if the removed connection is from the overflow
                 // menu, or if we just moved the last connection out from the menu
-                if (this._overflowItem.menu.length == 0) {
+                if (this._overflowItem.menu.numMenuItems == 0) {
                     this._overflowItem.destroy();
                     this._overflowItem = null;
                 }
@@ -1494,18 +1498,16 @@ NMDeviceWireless.prototype = {
         }
 
         if(apObj.connections.length > 0) {
-            if (apObj.connections.length == 1)
+            if (apObj.connections.length == 1) {
                 apObj.item = this._createAPItem(apObj.connections[0], apObj, false);
-            else {
+            } else {
                 let title = apObj.ssidText;
                 apObj.item = new PopupMenu.PopupSubMenuMenuItem(title);
-                apObj.item._apObj = apObj;
                 for (let i = 0; i < apObj.connections.length; i++)
                     apObj.item.menu.addMenuItem(this._createAPItem(apObj.connections[i], apObj, true));
             }
         } else {
             apObj.item = new NMNetworkMenuItem(apObj.accessPoints);
-            apObj.item._apObj = apObj;
             apObj.item.connect('activate', Lang.bind(this, function() {
                 let accessPoints = sortAccessPoints(apObj.accessPoints);
                 if (   (accessPoints[0]._secType == NMAccessPointSecurity.WPA2_ENT)
@@ -1520,6 +1522,8 @@ NMDeviceWireless.prototype = {
                 }
             }));
         }
+        apObj.item._apObj = apObj;
+
         if (position < NUM_VISIBLE_NETWORKS) {
             apObj.isMore = false;
             this.section.addMenuItem(apObj.item, position);